<?php

namespace XWAM\Addon\POrgCustomer\Model;

/**
 * CustomerAppointmentModel 类
 *
 * @since VER:1.0; DATE:2016-1-27; AUTHOR:SoChishun; EMAIL:14507247@qq.com; DESC:Added.
 */
class CustomerAppointmentModel extends \XWAM\Model\AppbaseModel {
    protected $tableName='t_porg_customer_appointment';
        
    // 保存预约记录 2016-1-27
    function save_appointment() {
        $rules = array(
            array('appointment_time', 'require', '预约时间无效!', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
            array('customer_id', 'require', '客户编号无效!', self::MUST_VALIDATE, 'regex', self::MODEL_INSERT),
        );
        if (!$this->validate($rules)->create()) {
            return $this->returnMsg(false, $this->error);
        }
        if (empty($this->id)) {
            $result = $this->add();
        } else {
            $result = $this->save();
        }
        return $this->returnMsg($result);
    }

    function delete_customer($id) {
        $result = $this->delete($id);
        return $this->returnMsg($result);
    }
}
